<?php

namespace App\Wechat\Remind\Commands;

use App\Wechat\Remind\Jobs\sendWxRemind;
use App\Wechat\Remind\Models\Remind;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\Dispatchable;

class sendRemind extends Command
{
	use Dispatchable;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'remind:wechat';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'send wechat remind to user';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $reminds = Remind::query()->where([
        	['date', '=', date('Y-m-d')],
	        ['time', '=', date('H:i:00')],
	        ['status', '=', 0],
	        ['is_deleted', '=', 0]
        ])->get();
        foreach ($reminds as $remind){
	        sendWxRemind::dispatch($remind)->onQueue('wx_remind');
        }
    }
}
